package com.hutu.controller.biz.admin;

import com.hutu.service.biz.ModuleService;
import com.hutu.model.biz.Module;
import javax.annotation.Resource;

import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;

import java.util.List;
import com.hutu.model.resp.ResponseVo;
/**
 * <p>
 * 表信息 Controller
 * </p>
 *
 * @author admin
 * @since 2023-07-19
 */
@RestController
@RequestMapping("/admin/module")
@Api(tags = "模板信息")
public class ModuleController {
    @Resource
    private ModuleService moduleService;

    @ApiOperation("新增")
    @PostMapping("/add")
    public ResponseVo add(@RequestBody Module module){
        return this.moduleService.add(module);
    }

    @ApiOperation("逻辑删除")
    @DeleteMapping("/{id}")
    public ResponseVo delete(@PathVariable Integer id){
        return this.moduleService.deleteById(id);
    }

    @ApiOperation("批量逻辑删除")
    @DeleteMapping("/batch/{ids}")
    public ResponseVo deleteBatch(@PathVariable List<Integer> ids){
        return this.moduleService.deleteBatch(ids);
    }

    @ApiOperation("编辑更新")
    @PutMapping
    public ResponseVo edit(@RequestBody Module module){
        return this.moduleService.edit(module);
    }

    @ApiOperation("查询")
    @GetMapping("/{id}")
    public ResponseVo findById(@PathVariable Integer id){
        return this.moduleService.findById(id);
    }

    @ApiOperation("分页条件查询")
    @PostMapping("page")
    public ResponseVo list(@RequestParam(defaultValue = "1") Integer current,@RequestParam(defaultValue = "10") Integer size,String projectId){
        return this.moduleService.list(current,size,projectId);
    }

    @ApiOperation("查询通用模板")
    @GetMapping("getCommonList")
    public ResponseVo getCommonList(String projectId){
        return this.moduleService.getCommonList(projectId);
    }
    @ApiOperation("根据通用模板生成代码")
    @GetMapping("createCommonModule")
    public ResponseVo createCommonModule(String moduleId,String fields){
        return this.moduleService.createCommonModule(moduleId,fields);
    }

}

